<?php
namespace app\common\util;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/10/10 0010
 * Time: 20:24
 */
class Random{

    public static function rand($len,$type="lower"){
        $res = "";
        $alpha = [
            'string'=>"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",
            'number'=>"0123456789",
            "lower"=>"abcdefghijklmnopqrstuvwxyz0123456789"
        ];
        $max = strlen($alpha[$type]);
        for($i = 0; $i<$len;$i++){
            $res .= $alpha[$type][rand(0,$max-1)];
        }

        return $res;
    }
}